﻿using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Text;
using SX.Utils; 

namespace SX.Web.Framework.Permissions
{
    public class ScopePermissionHandler : IPermissionHandler
    {
        IPermissionService _service;
        public ScopePermissionHandler(IPermissionService service) {
            _service = service;
        }
        public bool HasPermission(ClaimsPrincipal principal, string permissionName)
        {
            var userid = CommonHelper.ToInt64( principal.FindFirstValue("userid"));
            if (userid == 0) return false; 
            return _service.CheckPermission(userid, permissionName);
        }
    }
}
